Practical Datatype Specializations with Phantom Types and Recursion Schemes

نویسندگان

  • Matthew Fluet
  • Riccardo Pucella
چکیده

Datatype specialization is a form of subtyping that captures program invariants on data structures that are expressed using the convenient and intuitive datatype notation. Of particular interest are structural invariants such as well-formedness. We investigate the use of phantom types for describing datatype specializations. We show that it is possible to express statically-checked specializations within the type system of Standard ML. We also show that this can be done in a way that does not lose useful programming facilities such as pattern matching in case expressions.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Constraint-Based Type Inference for Guarded Algebraic Data Types

Guarded algebraic data types subsume the concepts known in the literature as indexed types, guarded recursive datatype constructors, and first-class phantom types, and are closely related to inductive types. They have the distinguishing feature that, when typechecking a function defined by cases, every branch may be checked under different typing assumptions. This mechanism allows exploiting th...

متن کامل

Datatypes and Subtyping

We study a calculus with both subtyping and datatype deenitions. Our primary goal is to understand the interaction of subtyping with mutually recursive types, which raises diiculties beyond those addressed in previous studies. A second aim is to clarify the relations between structural subtyping and the user-declared subtyping found in languages such as C++, Eiiel, and Java.

متن کامل

Transparent and Opaque Interpretations of Datatypes

Standard ML employs an opaque (or generative) interpretation of datatype speci cations, in which every datatype speci cation provides a new, abstract type that is di erent from any other type, including other identically speci ed datatypes. An alternative interpretation is the transparent one, in which a datatype speci cation exposes the underlying recursive type implementation of the datatype....

متن کامل

Recursion on Nested Datatypes in Dependent Type Theory

Nested datatypes are families of datatypes that are indexed over all types and where the datatype constructors relate different members of the family. This may be used to represent variable binding or to maintain certain invariants through typing. In dependent type theory, a major concern is the termination of all expressible programs, so that types that depend on object terms can still be type...

متن کامل

First-Class Phantom Types

Classical phantom types are datatypes in which type constraints are expressed using type variables that do not appear in the datatype cases themselves. They can be used to embed typed languages into Haskell or ML. However, while such encodings guarantee that only wellformed data can be constructed, they do not permit type-safe deconstruction without additional tagging and run-time checks. We in...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Electr. Notes Theor. Comput. Sci.

دوره 148  شماره 

صفحات  -

تاریخ انتشار 2006